package com.example.service;

import com.example.server.CDCServer;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class CDCServerServiceImpl implements CDCServerService, InitializingBean, DisposableBean {

    private CDCServer cdcServer;

    private long serverId;

    private String host;

    private int port;

    private String db;

    private String username;

    private String password;

    @Override
    public void afterPropertiesSet() throws Exception {
        this.cdcServer = new CDCServer(serverId, host, port, db, username, password);
        this.cdcServer.start();
    }

    @Override
    public void destroy() throws Exception {
        this.cdcServer.stop();
    }

    /////////////////////////////////////////////////

    public long getServerId() {
        return serverId;
    }

    public void setServerId(long serverId) {
        this.serverId = serverId;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getDb() {
        return db;
    }

    public void setDb(String db) {
        this.db = db;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
